<?php
class CiuplansController extends AppController {

	var $name = 'Ciuplans';
        var $components = array('Session');
	var $paginate = array(
        'limit' => 12,
        'order' => array(
            'Ciuplan.id' => 'asc'
             )
        );
	function index() {
		$this->Ciuplan->recursive = 0;
		$this->set('ciuplans', $this->paginate('Ciuplan',array('Ciuplan.id !='=>5)));// No muestra el plan ninguno
	}   

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid ciuplan', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('ciuplan', $this->Ciuplan->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Ciuplan->create();
			if ($this->Ciuplan->save($this->data)) {
				$this->Session->setFlash(__('The ciuplan has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The ciuplan could not be saved. Please, try again.', true));
			}
		}
                $ciulanguages = $this->Ciuplan->Ciulanguage->find('list',array('conditions' => array('Ciulanguage.id !='=>'5')));// 5 para que no tenga encuenta el idiomas ninguno

                $this->set(compact('ciulanguages'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid ciuplan', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Ciuplan->save($this->data)) {
				$this->Session->setFlash(__('The ciuplan has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The ciuplan could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Ciuplan->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for ciuplan', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Ciuplan->delete($id)) {
			$this->Session->setFlash(__('Ciuplan deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Ciuplan was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
